package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.User;
import cn.wolfcode.trip.base.domain.Vip;
import cn.wolfcode.trip.base.mapper.SearchMapper;
import cn.wolfcode.trip.base.mapper.UserMapper;
import cn.wolfcode.trip.base.mapper.VipMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IVipService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class VipServiceImpl implements IVipService {


    @Autowired
    private VipMapper vipMapper;

    @Autowired
    private UserMapper userMapper;

    @Override
    public PageInfo query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<Vip> list= vipMapper.selectForLis(qo);
        return new PageInfo(list);
    }

    @Override
    public Vip getById(Long id) {
        return vipMapper.selectByPrimaryKey(id);
    }

    @Override
    public User isVIP(User user) {
        Long id = user.getId();
        Integer isVIP = user.getIsVIP();
        return userMapper.selectIsVip(isVIP,id);
    }


}
